package net.wapproject.dao.impl;

import java.util.List;

import net.wapproject.bean.Category;
import net.wapproject.dao.ICategoryDAO;

import org.hibernate.Criteria;
import org.hibernate.criterion.Expression;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class CategoryDaoImpl extends HibernateDaoSupport implements
		ICategoryDAO {

	@SuppressWarnings("unchecked")
	@Override
	public List<Category> getParentCategory() {
		Criteria criteria = getSession().createCriteria(Category.class);
		criteria.add(Expression.eq("parentId", 0));
		
		return criteria.list();
	}

	@Override
	public List<Category> getCategoryByParentId(Integer parentId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void saveOrUpdate(Category category) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(Category category) {
		// TODO Auto-generated method stub

	}

	@Override
	public Category getCategoryById(Integer id) {
		Criteria criteria = getSession().createCriteria(Category.class);
		criteria.add(Expression.eq("id", id));
		return (Category) criteria.list().get(0);
	}

}
